package cn.iocoder.yudao.module.shop.dal.mysql.storerecord;

import java.time.LocalDateTime;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.shop.dal.dataobject.storerecord.ShopStoreRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.shop.controller.admin.storerecord.vo.*;

/**
 * 库存消耗记录 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface ShopStoreRecordMapper extends BaseMapperX<ShopStoreRecordDO> {

    default PageResult<ShopStoreRecordDO> selectPage(ShopStoreRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopStoreRecordDO>()
                .betweenIfPresent(ShopStoreRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopStoreRecordDO::getId));
    }

    default List<ShopStoreRecordDO> selectList(ShopStoreRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShopStoreRecordDO>()
                .betweenIfPresent(ShopStoreRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopStoreRecordDO::getId));
    }

    default List<ShopStoreRecordDO> selectListByTime(LocalDateTime startTime, LocalDateTime endTime, Long tenantId, Integer type){
        return selectList(new LambdaQueryWrapperX<ShopStoreRecordDO>()
                .eq(ShopStoreRecordDO::getTenantId, tenantId)
                .eqIfPresent(ShopStoreRecordDO::getType, type)
                .between(ShopStoreRecordDO::getCreateTime, startTime, endTime));
    }

}
